﻿package mortal.game.view.autoFight.render
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.game.view.autoFight.data.*;
    import mortal.game.view.skill.panel.render.*;
    import mortal.game.view.systemSetting.*;

    public class AFWizardSkillRender extends GSprite
    {
        protected var _item:SkillItem;
        protected var _myData:AFSkillData;
        private var _selectedCallback:Function;

        public function AFWizardSkillRender()
        {
            return;
        }// end function

        public function get selectedCallback() : Function
        {
            return this._selectedCallback;
        }// end function

        public function set selectedCallback(param1:Function) : void
        {
            this._selectedCallback = param1;
            return;
        }// end function

        public function setSelected(param1:Boolean) : void
        {
            this._myData.isActive = param1;
            this.refreshMe();
            return;
        }// end function

        public function refreshMe() : void
        {
            this.data = this._myData;
            return;
        }// end function

        protected function selectedChangeHandler(event:MouseEvent) : void
        {
            if (this._myData.isActive)
            {
                return;
            }
            if (this.selectedCallback != null)
            {
                this._selectedCallback.apply();
            }
            this.setSelected(true);
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this._myData = param1 as AFSkillData;
            if (this._myData.info == null || !this._myData.info.learned)
            {
                this.mouseEnabled = false;
                return;
            }
            this.mouseEnabled = true;
            this._item.skillInfo = this._myData.info;
            if (this._myData.isActive && ClientSetting.local.getIsDone(IsDoneType.UseWizardSkill))
            {
                this._item.filters = [];
            }
            else
            {
                this._item.filters = [FilterConst.colorFilter];
            }
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._item = UICompomentPool.getUICompoment(SkillItem) as SkillItem;
            this._item.y = 6;
            this.addChild(this._item);
            this._item.isDragAble = false;
            this._item.isDropAble = false;
            this._item.isThrowAble = false;
            this._item.isShowFreezingEffect = false;
            this._item.isShowLeftTimeEffect = false;
            this._item.isShowToolTip = true;
            this._item.setSize(42, 42);
            this._item.setBg("shortcutItemBg", 3, 3);
            this.configEventListener(MouseEvent.CLICK, this.selectedChangeHandler);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._item.dispose(param1);
            this._item = null;
            return;
        }// end function

    }
}
